package com.hfh.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by yzYang on 2014/11/22.
 */
public class  WeekDayUtil {

    public static String getWeekDay(String dateTime) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d = sdf.parse(dateTime);
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        String weekday = "";
        switch (c.get(Calendar.DAY_OF_WEEK)-1){
            case 1:
                weekday = "周一";
                break;
            case 2:
                weekday = "周二";
                break;
            case 3:
                weekday = "周三";
                break;
            case 4:
                weekday = "周四";
                break;
            case 5:
                weekday = "周五";
                break;
            case 6:
                weekday = "周六";
                break;
            case 0:
                weekday = "周日";
                break;
        }
        return weekday;
    }
    
    public static void main(String []args){
        try{
            getWeekDay("2014-11-17 22:23:21.0");
            getWeekDay("2014-11-18 22:23:21.0");
            getWeekDay("2014-11-19 22:23:21.0");
            getWeekDay("2014-11-20 22:23:21.0");
            getWeekDay("2014-11-21 22:23:21.0");
            getWeekDay("2014-11-22 22:23:21.0");
            getWeekDay("2014-11-23 22:23:21.0");
            getWeekDay("2014-11-24 22:23:21.0");
            getWeekDay("2014-11-25 22:23:21.0");
            System.out.println(System.getProperty("os.name"));

        }catch (Exception e){

        }

    }

}
